package cloud.xiangyixiang.www.spring.boot.java.basics.utils;

import cloud.xiangyixiang.www.spring.boot.java.basics.service.IStudyDerivation;

/**
 * <p>
 * Lambda 推导
 * </p>
 *
 * @author weixin
 * @date 2023/9/18 15:00
 */
public class LambdaDerivationUtil {

    public static void main(String[] args) {
        // 匿名内部类
        IStudyDerivation function = new IStudyDerivation() {
            @Override
            public void study(String technology, int time) {
                System.out.println("匿名内部类,"+technology+time);
            }
        };
        function.study("java", 8);

        // Lambda表达式改造（将类名和方法名去掉）
        IStudyDerivation function1 = (String technology,int time)->{
            System.out.println("Lambda表达式改造（将类名和方法名去掉）"+technology+time);
        };
        function1.study("java", 8);

        // 一级进化（去掉数据类型）
        IStudyDerivation function2 = ((technology, time) -> {
            System.out.println("一级进化（去掉数据类型）"+technology+time);
        });
        function2.study("java",8);

        // 二级进化（简化括号）,一般进行一次进化就可以了，二级进化没必要
        IStudyDerivation function3 = ((technology, time) -> System.out.println("二级进化（简化括号）"+technology+time));
        function3.study("java",8);
    }

}
